<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Coupon
 *
 * @property int $id
 * @property string|null $name 优惠券名称
 * @property float|null $money 优惠金额
 * @property string|null $start_time
 * @property string|null $end_time
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Coupon whereEndTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Coupon whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Coupon whereMoney($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Coupon whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Coupon whereStartTime($value)
 * @mixin \Eloquent
 * @property string|null $type 优惠券类型
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Coupon whereType($value)
 */
class Coupon extends Model
{
    protected $table='coupons';
    const UPDATED_AT = null;
    const CREATED_AT = null;
    const FIRSTCHARGE='first';
    const DISPLAY='display';
    public $timestamps=false;
    static $typeMap=[
        self::FIRSTCHARGE=>'首购优惠券',
        self::DISPLAY=>'无限制',
    ];
    public static function getSelectOptions()
    {
        $options = \DB::table('coupons')->select('id','name as text')->get();
        $selectOption = [];
        foreach ($options as $option){
            $selectOption[$option->id] = $option->text;
        }
        return $selectOption;
    }

}
